package org.agilelang.object;

/*
 AgileLang - A fourth generation language(http://www.agilelang.org).

 Copyright (C) 2013 Roderick Cusirramos (roderick20@hotmail.com)

 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.agilelang.object.attributes.Event;
import org.agilelang.object.attributes.Function;
import org.agilelang.object.attributes.View;
import org.agilelang.object.attributes.ViewForm;
import org.agilelang.object.attributes.ViewReport;

@XmlRootElement(name = "controller")
public class Controller implements Serializable {

    @XmlAttribute
    public String name = "";
    public String caption = "";
    public String description = "";
    public String type = "simple";//scaffold, transaction
    public String extend = "";
    @XmlElement(name = "view")
    public List<View> views = new ArrayList<View>();
    @XmlElement(name = "function")
    public List<Function> functions = new ArrayList<Function>();
    @XmlElement(name = "form")
    public List<ViewForm> forms = new ArrayList<ViewForm>();
    @XmlElement(name = "report")
    public List<ViewReport> reports = new ArrayList<ViewReport>();

    public void addView(View view) {
        this.views.add(view);
    }

    public void addFunction(Function function) {
        this.functions.add(function);
    }

    public void addViewForm(ViewForm form) {
        this.forms.add(form);
    }

    public void addViewReport(ViewReport report) {
        this.reports.add(report);
    }
    //--------------------------------------------------------------------------
    //scaffold
    public String model_scaffold = "";
    //--------------------------------------------------------------------------
    //transaction
    public String model_header = "";
    public String model_detail = "";
    public String model_header_description = "";
    public String model_detail_description = "";
    public String relation_header = "";
    public String relation_detail = "";
    public String relation_field = "";
    public String relation_description = "";
    
    public String attributesIndex = "";
    public String orderIndex = "";
    public String conditionsIndex = "";
    
    public String attributesView = "";
    
    public String attributesAdd = "";
    public String defaultsAdd = "";
    
    public String attributesUpdate = "";
    public String defaultsUpdate = "";
    
    public String addCondition = "";
    
    @XmlElement(name = "event")
    public List<Event> events = new ArrayList<Event>();

    public void addEvent(Event event) {
        this.events.add(event);
    }
    //--------------------------------------------------------------------------  
}
